#include "cubes.h"
#include "ui_cubes.h"
#include "QPainter"
#include "QTimer"
#include "QKeyEvent"


QRect Cubes::Left(QRect a)
{
    a.setLeft(a.left()-25);
    a.setRight(a.right()-25);
    return a;
}
QRect Cubes::Right(QRect a)
{
    a.setLeft(a.left()+25);
    a.setRight(a.right()+25);
    return a;
}
QRect Cubes::Down(QRect a)
{
    a.setBottom(a.bottom()+25);
    a.setTop(a.top()+25);
    return a;
}
QRect Cubes::Up(QRect a)
{
    a.setBottom(a.bottom()-25);
    a.setTop(a.top()-25);
    return a;
}
QVector<QRect> Cubes::Rotate()
{
    QVector<QRect> a;
    a.resize(4);
    switch (cCube)
    {
        case 1:
        {
            CubeLeft = Right(Down(CubeLeft));
            CubeRight = Left(Left(CubeRight));
            CubeBottom = Down(Down(CubeBottom));
            CubeTop = Left(Up(CubeTop));
            cCube = 8;
            break;
        }
        case 2:
        {
            CubeLeft = Right(CubeLeft);
            CubeBottom = Down(CubeBottom);
            cCube = 9;
            break;
        }
        case 3:
        {
            break;
        }
        case 4:
        {
            CubeTop = Right(CubeTop);
            CubeRight = Right(Up(CubeRight));
            CubeBottom = Up(CubeBottom);
            cCube = 12;
            break;
        }
        case 5:
        {
            CubeRight = Down(Up(Right(CubeRight)));
            CubeTop = Down(Down(Right(CubeTop)));
            CubeBottom = Down(CubeBottom);
            CubeLeft = Down(CubeLeft);
            cCube = 13;
            break;
        }
        case 6:
        {
            CubeTop = Left(Down(CubeTop));
            CubeRight = Right(Down(CubeRight));
            cCube = 16;
            break;
        }
        case 7:
        {
            CubeTop = Down(CubeTop);
            CubeBottom = Right(CubeBottom);
            CubeRight = Right(Down(CubeRight));
            cCube = 19;
            break;
        }
        case 8:
        {
            CubeTop = Right(Down(CubeTop));
            CubeRight = Right(Right(CubeRight));
            CubeBottom = Up(Up(CubeBottom));
            CubeLeft = Left(Up(CubeLeft));
            cCube = 1;
            break;
        }
        case 9:
        {
            CubeLeft = Left(CubeLeft);
            CubeTop = Down(CubeTop);
            cCube = 10;
            break;
        }
        case 10:
        {
            CubeTop = Up(CubeTop);
            CubeRight = Left(CubeRight);
            cCube = 11;
            break;
        }
        case 11:
        {
            CubeBottom = Up(CubeBottom);
            CubeRight = Right(CubeRight);
            cCube = 2;
            break;
        }
        case 12:
        {
            CubeTop = Left(CubeTop);
            CubeRight = Left(Down(CubeRight));
            CubeBottom = Down(CubeBottom);
            cCube = 4;
            break;
        }
        case 13:
        {
            CubeBottom = Right(CubeBottom);
            CubeRight = Left(CubeRight);
            CubeTop = Up(CubeTop);
            CubeLeft = Up(CubeLeft);
            cCube = 14;
            break;
        }
        case 14:
        {
            CubeBottom = Left(Up(CubeBottom));
            CubeLeft = Left(Down(CubeLeft));
            cCube = 15;
            break;
        }
        case 15:
        {
            CubeTop = Left(Up(CubeTop));
            CubeLeft = Up(Right(CubeLeft));
            cCube = 5;
            break;
        }
        case 16:
        {
            CubeRight = Up(Left(CubeRight));
            CubeBottom = Down(Left(CubeBottom));
            cCube = 17;
            break;
        }
        case 17:
        {
            CubeLeft = Left(Up(CubeLeft));
            CubeBottom = Up(Right(CubeBottom));
            cCube = 18;
            break;
        }
        case 18:
        {
            CubeTop = Up(Right(CubeTop));
            CubeLeft = Right(Down(CubeLeft));
            cCube = 6;
            break;
        }
        case 19:
        {
            CubeTop = Up(CubeTop);
            CubeBottom = Left(CubeBottom);
            CubeRight = Left(Up(CubeRight));
            cCube = 7;
            break;
        }
    }
    a[0] = CubeLeft;
    a[1] = CubeRight;
    a[2] = CubeTop;
    a[3] = CubeBottom;
    return a;
}
